package org.batatasframework.support.database.values;

import java.util.List;

import org.batatasframework.support.database.sql.field.FieldElement;
import org.batatasframework.support.database.sql.field.MultipleSelectFragment;


public class ArrayValueHolder extends AbstractMultipleValueHolder{

	public ArrayValueHolder(MultipleSelectFragment field, List<? extends FieldElement> relations) {
		super(field, relations);
	}

	@Override
	protected FieldValue read(Object[] args) throws Exception {
		return new ArrayValue(args);
	}

	@Override
	public StatisticsTotal createStatistics() {
		return null;
	}
	
	class ArrayValue extends AbstractValue<Object[]>{
		public ArrayValue(Object[] args) {
			super(args);
		}

		@Override
		public Object targetValue() {
			StringBuffer sb = new StringBuffer();
			for(Object arg : value){
				if(null != arg){
					sb.append(arg);
				}
			}
			return sb;
		}

		public List<? extends FieldElement> getRelations() {
			return relations;
		}
	}

}
